package com.example.admin.goodnews.activity;

import android.content.Intent;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.adapter.PhotoWallAdapter;

import java.util.ArrayList;

/**
 * 相册页面
 * Created by admin on 2016/10/22.
 */

public class GalleryActivity extends AppCompatActivity {
    private ImageView iv_back_gallery;// 标题栏返回按钮
    private GridView gridview_meitudaquan;
    private PhotoWallAdapter photoWallAdapter;
    private ArrayList<String> gallerylist = new ArrayList<>();// 放置图片网址的集合

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gallery);
        initView();// 初始化控件
        initData();// 设置数据
        initEvent();// 点击事件
    }

    private void initView() {
        iv_back_gallery = (ImageView) findViewById(R.id.iv_back_gallery);// 标题栏返回按钮
        gridview_meitudaquan = (GridView) findViewById(R.id.gridview_meitudaquan);
    }

    private void initData() {
        Intent intent = getIntent();
//        Bundle bundle = intent.getBundleExtra("gallery");
//        gallerylist = bundle.getStringArrayList("gallerylist");
        gallerylist = intent.getStringArrayListExtra("gallerylist");
        photoWallAdapter = new PhotoWallAdapter(GalleryActivity.this, gallerylist);
        gridview_meitudaquan.setAdapter(photoWallAdapter);
    }

    private void initEvent() {
        // 标题栏返回
        iv_back_gallery.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}